<template>
<div>
    <button @click="sonClick"> 演示emit（查看console） </button><br>
    演示defineProps{{msg}}
</div>
<div>
    <span>从父组件传来的值，通过inject注入:{{sondata}}</span>
</div>
</template>

<script setup>
import { inject } from 'vue'
import pac from '../../package.json'

//将json转为Obj
console.log(pac)

//父组件定义属性
const props = defineProps({
    msg: String
});

//传递自定义事件
const emit = defineEmits(['myclick','myclick2'])
const sonClick = function() {
    emit('myclick')
}


//inject
const sondata = inject('fatherData')
</script>


<style scoped lang="less">
div {
    botton {
        background-color: aquamarine;
    }
}
</style>